dnl Process this file with autoconf to produce a configure script.

AC_INIT([colormap], [1.0.1], [reunanen@ftml.net])
AC_CONFIG_HEADERS([config.h])

AC_CONFIG_AUX_DIR([admin])
AC_CANONICAL_SYSTEM 

AM_INIT_AUTOMAKE() 

dnl AC_CONFIG_MACRO_DIR([macros])

AC_PROG_CXX
dnl AC_ISC_POSIX
dnl AC_PROG_CPP
dnl AM_PROG_CC_C_O
AC_PROG_INSTALL
 
dnl ====== CFITSIO =============================
PKG_CHECK_MODULES([CFITSIO], [cfitsio])

dnl ====== LUA =================================
dnl Too simple check, but works on my system
PKG_CHECK_MODULES([LUA], [lua5.1])

dnl ====== PGPLOT ==============================
dnl Simple test for pgplot. 
AC_CHECK_LIB(cpgplot, cpgbeg, 
  [PGPLOT_LIBS="-lcpgplot -lpgplot"],
  [AC_MSG_ERROR([Cannot find libcpgplot])], [-lpgplot -lX11 -lpng]
)
AC_SUBST([PGPLOT_LIBS])

dnl Needed also for pgplot
PKG_CHECK_MODULES(X11, x11) 
PKG_CHECK_MODULES(LIBPNG, libpng) 

dnl ====== Needed in Solaris/SunOS =============
AC_CHECK_LIB(socket, socket, [LIBS="$LIBS -lsocket"])
AC_CHECK_FUNCS(gethostbyname, , [AC_CHECK_LIB(nsl, gethostbyname), , LIBS="$LIBS -lnsl"])

dnl ====== Output ==============================
AC_OUTPUT(Makefile src/Makefile)

dnl ====== Print configuration =================
echo "

Configuration:

  Detected OS:      ${host_os}
  Software version: ${VERSION}
  Install path:     ${prefix}
  Compiler:         ${CC}
  Compiler flags:   ${CFLAGS}
  Linker flags:     ${LIBS}

"
